<?php

namespace App\Http\Controllers;

use App\Logic\Json;
use App\Models\Goods;
use Illuminate\Http\Request;

use App\Http\Requests;

class GoodsController extends Controller
{
    //
    public function index(Request $request)
    {
        header('Access-Control-Allow-Origin:*');
//        header('Access-Control-Allow-Origin:http://A.abc.com');

        $where = [];
        if($request->query->has('name') && $request->query->get('name')) $where[] = ['goods_name' , 'like' , '%' . $request->query->get('name') . '%'];

        //orderBy 里面添加数组**



        $goods = Goods::where($where)->orderBy('id','DESC')->paginate(20);
        return Json::success('success',$goods);
    }
}
